#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
User: lyj
DateTime: 2012-04-14 21:54:00

"""

__author__ = 'lyj'



import random, time
import producer
p = producer.Producer(exchange_name='integers', host='localhost', userid='guest', password='guest')
while True:
    # generate a random integer between 1 and 100 included
    i = random.randint(1, 100)
    if i % 2 == 0:
        key = 'even'
    else:
        key = 'odd'
    p.publish(str(i), key)
    print 'integer: %d' % i
    time.sleep(1)
